Jade = require 'koa-jade'

config = require './config'

jadeLocals = {}
jadeLocals.toYMDHM = (date) ->
    date && date.getYear &&
        ("#{date.getFullYear()}-#{date.getMonth() + 1}-#{date.getDate()} #{date.getHours()}:#{date.getMinutes()}")
jadeLocals.toYMD = (date) ->
    date && date.getYear &&
        ("#{date.getFullYear()}-#{date.getMonth() + 1}-#{date.getDate()}")

jade = new Jade({
    viewPath: config.serverJadePath,
    locals: jadeLocals,
    noCache: process.env.DEV == '1'
})

exports.jade = jade
exports.jadeLocals = jadeLocals